home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 395_01 / typing / source / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-19  |  2.3 KB  |  89 lines

  1. /* #ident "@(#) init.c - Typing Tutor initialisation." */
  2.  
  3. #include "tt.h"
  4. #include "externals.h"
  5.  
  6. static char *title={"Christopher Sawtell's Typing Tutor"},
  7.             *lesson_file_name={"/usr/local/lib/tt.text"};
  8.  
  9. static char *copyright[] = {
  10. "Copyright (C) 1993 Christopher Sawtell.",
  11. "Permission is granted to any individual or institution to use, copy, or",
  12. "redistribute this package of programs so long as it is not modified in",
  13. "any way whatsoever without the author's knowledge or sold for profit.",
  14. NULL
  15. };
  16.  
  17. static char *disclaimer[] = {
  18. "LIKE ANYTHING ELSE WHICH IS FREE, \"TT\" AND ITS ASSOCIATED FILES ARE",
  19. "PROVIDED \"AS IS\" AND COME WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED OR",
  20. "IMPLIED. IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DAMAGES",
  21. "RESULTING FROM THE USE OF THIS SOFTWARE.",
  22. NULL
  23. };
  24.  
  25. init()
  26. {
  27.   int x, y;
  28.   char **ch_pp;
  29.  
  30. /*
  31.  * First open a screen and then two curses windows
  32.  *    - the top one for lesson instructions
  33.  *      and the bottom for the fields into which to type.
  34.  */
  35.  
  36. /* allocate an input buffer */
  37.  
  38.   if (( ipbp = ipbuffer = ( char * ) malloc ( COLS + 1 )) == NULL )
  39.   { perror ( title );
  40.     exit ( ERR );
  41.     }
  42.  
  43. /* open lesson text file  */
  44.  
  45.   if (( lesson = ( FILE * ) fopen ( lesson_file_name, "r" )) == NULL )
  46.   { perror ( title );
  47.     exit ( ERR );
  48.     }
  49.  
  50.   initscr();
  51.   refresh ();
  52.   nonl();
  53.   noecho();
  54.   cbreak();
  55.  
  56. /* Create windows */
  57.  
  58.   attron ( A_UNDERLINE );
  59.   move ( TITLE_LINE, (COLS-strlen(title))/2);       /* Put program title up. */
  60.   printw ( title );          /*  Do it this way so that the title is always */
  61.                              /*  in the middle of top line irrespective of    */
  62.                              /*  the number of screen columns.                */
  63.   attroff ( A_UNDERLINE );
  64.   wnoutrefresh ( stdscr );
  65.   top_window = newwin ( TOP_WINDOW_HEIGHT,
  66.                         TOP_WINDOW_WIDTH,
  67.                     TOP_WINDOW_ROW,
  68.                         TOP_WINDOW_COLUMN
  69.                     );
  70.   wattrset ( top_window, A_NORMAL );
  71.   werase ( top_window );
  72.   middle_window = newwin ( MIDDLE_WINDOW_HEIGHT,
  73.                            MIDDLE_WINDOW_WIDTH,
  74.                            MIDDLE_WINDOW_ROW,
  75.                        MIDDLE_WINDOW_COLUMN
  76.                        );
  77.   wattrset ( middle_window, A_NORMAL );
  78.   werase ( middle_window );
  79.   bottom_window = newwin ( BOTTOM_WINDOW_HEIGHT,
  80.                            BOTTOM_WINDOW_WIDTH,
  81.                    BOTTOM_WINDOW_ROW,
  82.                BOTTOM_WINDOW_COLUMN
  83.                );
  84.   wattrset ( bottom_window, A_NORMAL );
  85.   werase ( bottom_window );
  86.   current_window = top_window;
  87.   }
  88.  
  89.